package com.bit.musicserver.controller;


import com.bit.musicserver.Service.LoveMusicService;
import com.bit.musicserver.Tools.Constat;
import com.bit.musicserver.Tools.ResponseBodyMessage;
import com.bit.musicserver.mapper.LoveMusicMapper;
import com.bit.musicserver.model.Music;
import com.bit.musicserver.model.User;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/loveMusic")
public class LoveMusicController {
    @Resource
    private LoveMusicMapper loveMusicMapper;
    @Resource
    private LoveMusicService loveMusicService;
    /*收藏音乐*/
    @RequestMapping("/likeMusic")
    public ResponseBodyMessage<Boolean> likeMusicController(@RequestParam(value = "id") String id, HttpServletRequest request) {
        return loveMusicService.likeMusic(id, request);
    }

    /*查找收藏音乐*/
    @RequestMapping("/findLoveMusic")
    public ResponseBodyMessage<List<Music>> findLoveMusicController(@RequestParam(required = false) String musicName,
                                                          HttpServletRequest request) {
       return loveMusicService.findLoveMusic(musicName, request);
    }

    /*取消收藏音乐*/
    @RequestMapping("/deleteLoveMusic")
    public ResponseBodyMessage<Boolean> deleteLoveMusicController(@RequestParam("id") String id, HttpServletRequest request) {
        return loveMusicService.deleteLoveMusic(id,request);
    }
}
